#ifndef AGENTINTHREAD_H
#define AGENTINTHREAD_H

#include <QObject>
#include <QHostAddress>
class AgentProtocol;
class AgentPush;

class AgentInThread : public QObject
{
    Q_OBJECT
public:
    explicit AgentInThread(QObject *parent = 0);
    ~AgentInThread();
signals:
    void sigSendDataToApp(QByteArray packet,QString appIP,quint16 appPort);

    void sigAgentDelete(QByteArray packet,QString appIP,quint16 appPort);
    void sigAgentGet(QByteArray packet,QString appIP,quint16 appPort);
    //void sigAgentPut(QByteArray packet,QString appIP,quint16 appPort);
    void sigAgentWatch(QByteArray packet,QString appIP,quint16 appPort);

    void sigErrorInfo(QByteArray errorInfo);

    void sigSetIPAnalyzeIncomeDatagram( QByteArray datagram,   QHostAddress parClientIP,
    quint16 parClientPort); //设置clientip和clientport，然后调用analyzeIncomeDatagram
public slots:
    void slotPacketToAgent(QByteArray packet,QString appIP,quint16 appPort);
private slots:
    void slotInit();

private:
    void createAgentTaskTimer(QByteArray packet,QString appIP,quint16 appPort);
    void createAgentTaskEventTrigger(QByteArray packet,QString appIP,quint16 appPort);
    void createAgentTaskDataThreshTrigger(QByteArray packet,QString appIP,quint16 appPort);
    void createAgentTaskDateTimeTrigger(QByteArray packet,QString appIP,quint16 appPort);

    AgentProtocol *agentProtocol;
    AgentPush *agentPush; //如果有新的task生成，则发送给感兴趣的App
};

#endif // AGENTINTHREAD_H
